<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>积分配置</title>
<script type="text/javascript">
	//查询符合条件的
	function searchRulePoint(){
		$('#rulepointinfo').datagrid('load',{
			rule_description:$('#rule_description').val(),
		});
	}	
	function formatOper(val,row,index){
		   return '<a href="#" onclick="openUpdateDialog('+index+')">修改规则</a>';  
	} 	
	//增加用户
	function updateRulePoint(){
		$("#update_fm").form("submit",{
			url:"updateRulePoint",
			onSubmit:function(){
				if($('#urule_point').val()==""){
					$.messager.alert("系统提示","请输入分数");
					return false;
				}
				if((/^(\-|\+)?\d+(\.\d+)?$ /.test($('#urule_point').val()))){
			        $.messager.alert("系统提示","规则分数一栏请输入数字");
			        return false;
				}

			},
			success:function(result){
				if(result==1){
					$.messager.alert("系统提示","修改成功");
					$("#update").dialog("close");
					$("#rulepointinfo").datagrid("reload");
				}else{
					$.messager.alert("系统提示","修改失败");
					return;
				}
			}
		});
	}
	function openUpdateDialog(index){	
	    $("#update").dialog("open");
	    var rows = $('#rulepointinfo').datagrid('getRows');
		var selectedRow = rows[index];	
	    if(selectedRow.length==0){
			$.messager.alert("系统提示","请选择要修改的数据！");
			return;
		}
	    
	    $("#urule_type").val(selectedRow.rule_type);
		$("#urule_description").html(selectedRow.rule_description);
		$("#urule_point").val(selectedRow.rule_point);
	}
	function closeUpdateDialog(){
		$("#update").dialog("close");
	}
</script>
<link rel="stylesheet" type="text/css"  href="../../easyui-1.5/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"  href="../../easyui-1.5/themes/icon.css" />
<script type="text/javascript" src="../../easyui-1.5/jquery.min.js"></script>
<script type="text/javascript" src="../../easyui-1.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../easyui-1.5/locale/easyui-lang-zh_CN.js"></script>
</head>
<body style="margin:5px">
	<table id="rulepointinfo" title="积分管理" class="easyui-datagrid" fitColumns="true" striped="true"
	 pagination="true" rownumbers="true" url="getRulePointList" fit="true" toolbar="#tb">
		<thead>
			<tr>
				<th field="cb" checkbox="true"></th>
				<th field="rule_type" width="50" align="center" hidden="true">规则类型</th>
				<th field="rule_description" width="200" align="center">规则描述</th>
				<th field="rule_point" width="50" align="center">规则分数</th>
				<th field="rule_op" width="60"  align="center" formatter="formatOper">操作</th>				
			</tr>
		</thead>
	</table>
	<div id="tb">
		<div>
		<form id="export" method="post">
		    <div>&nbsp;</div>
			&nbsp;规则描述：&nbsp;<input type="text" name="rule_description" id="rule_description" size="50"/>		
			<a href="javascript:searchRulePoint()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
			<div>&nbsp;</div>
			</form>		
		</div>
	</div>
	<div id="update" class="easyui-dialog" style="width: 750px;height: 300px;padding: 10px 20px"
		closed="true" buttons="#update-buttons" title="修改用户信息">
		<form id="update_fm" method="post">	
		            <div>&nbsp;</div>
		            <input type="text" name="rule_type" id="urule_type" size="50" hidden="true"/>	
					<div>&nbsp;</div>
					&nbsp;规则描述：&nbsp;
					<span name="rule_description" id="urule_description"></span>
					<!-- <textarea name="rule_description" id="urule_description" rows="3" cols="80" class="easyui-validatebox" editable="false"></textarea> -->
					<div>&nbsp;</div>
					&nbsp;规则分数：&nbsp;
					<input type="text" name="rule_point" id="urule_point" size="50" />	
		</form>
	</div>
	<div id="update-buttons">
		<a href="javascript:updateRulePoint()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
		<a href="javascript:closeUpdateDialog()" class="easyui-linkbutton" iconCls="icon-cancel">取消</a>
	</div>
	
</body>
</html>